package com.ruoyi.web.controller.market.account;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.BillInfoChannel;
import com.ruoyi.account.service.IBillInfoChannelService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.BillInfoChannelWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道账单信息Controller
 * 
 * @author ruoyi
 * @date 2023-02-02
 */
@Controller
@RequestMapping("/account/billChannel")
public class BillInfoChannelController extends BaseController
{
    private String prefix = "account/billChannel";

    @Autowired
    private IBillInfoChannelService billInfoChannelService;

    @RequiresPermissions("account:billChannel:view")
    @GetMapping()
    public String billChannel()
    {
        return prefix + "/billChannel";
    }

    /**
     * 查询渠道账单信息列表
     */
    @RequiresPermissions("account:billChannel:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BillInfoChannel billInfoChannel)
    {
        startPage();
        List<Map<String, Object>> mapList = billInfoChannelService.selectBillInfoChannelListMap(billInfoChannel);
        mapList = new BillInfoChannelWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出渠道账单信息列表
     */
    @RequiresPermissions("account:billChannel:export")
    @Log(title = "渠道账单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BillInfoChannel billInfoChannel)
    {
        List<BillInfoChannel> list = billInfoChannelService.selectBillInfoChannelList(billInfoChannel);
        ExcelUtil<BillInfoChannel> util = new ExcelUtil<BillInfoChannel>(BillInfoChannel.class);
        return util.exportExcel(list, "渠道账单信息数据");
    }

    /**
     * 新增渠道账单信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存渠道账单信息
     */
    @RequiresPermissions("account:billChannel:add")
    @Log(title = "渠道账单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BillInfoChannel billInfoChannel)
    {
        return toAjax(billInfoChannelService.insertBillInfoChannel(billInfoChannel));
    }

    /**
     * 修改渠道账单信息
     */
    @RequiresPermissions("account:billChannel:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BillInfoChannel billInfoChannel = billInfoChannelService.selectBillInfoChannelById(id);
        mmap.put("billInfoChannel", billInfoChannel);
        return prefix + "/edit";
    }

    /**
     * 修改保存渠道账单信息
     */
    @RequiresPermissions("account:billChannel:edit")
    @Log(title = "渠道账单信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BillInfoChannel billInfoChannel)
    {
        return toAjax(billInfoChannelService.updateBillInfoChannel(billInfoChannel));
    }

    /**
     * 删除渠道账单信息
     */
    @RequiresPermissions("account:billChannel:remove")
    @Log(title = "渠道账单信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(billInfoChannelService.deleteBillInfoChannelByIds(ids));
    }
}
